
module FM_Modulator
#(
    parameter BASEWIDTH = 10,
    parameter DEPTH=16,
    parameter Fmclk = 65000000
)
(
    input wire signed [BASEWIDTH-1:0] i_Baseband_Signal,
    input wire [31:0] i_CenterFreq,
    input wire [31:0] i_FreqOffset,
    input wire i_clk,
    input wire i_rst,
    output wire [DEPTH-1:0] o_WaveAddr,
	 input wire signed [BASEWIDTH-1:0] i_RAMData,
	 output wire signed [BASEWIDTH-1:0] o_FM_Signal
);

wire signed [BASEWIDTH:0] biased_base;
wire [31:0] startfreq;
wire [31:0] endfreq;

assign biased_base=i_Baseband_Signal+(1<<(BASEWIDTH-2));
assign startfreq=i_CenterFreq-(i_FreqOffset>>1);
assign endfreq=i_CenterFreq+(i_FreqOffset>>1);

LinearVCO 
#(
    .DEPTH(DEPTH),
    .iWIDTH(BASEWIDTH),
    .Fmclk(Fmclk)
)
FM_VCO
(
    .i_vtune(biased_base[BASEWIDTH-1:0]),
    .i_StartFreq(startfreq),
    .i_EndFreq(endfreq),
    .i_clk(i_clk),
    .i_rst(i_rst),
    .o_WaveAddr(o_WaveAddr)
);

assign o_FM_Signal=i_RAMData;
endmodule